var path = require("path");
//当以命令行运行webpack时工具会发现我们并没有提供的入口和出口文件此时此时会检查配置文件和读取文件
var htmlWebpackPlugin = require("html-webpack-plugin"); //生成一个内存中的页面
var VueLoaderPlugin = require("vue-loader/lib/plugin");
var webpack = require("webpack");
module.exports = {
  //入口
  entry: path.join(__dirname, "./src/main.js"),
  output: {
    path: path.join(__dirname, "./dist/"),
    filename: "bundel.js"
  },
  plugins: [
    new htmlWebpackPlugin({
      template: path.join(__dirname, "./src/index.html"),
      filename: "index.html"
    }),
    new VueLoaderPlugin(),
    new webpack.ProvidePlugin({
      $:"jquery",
      jQuery:"jquery"
    })
  ],
  module: {
    rules: [{
        test: /\.less$/,
        use: ["style-loader", "css-loader", "less-loader"]
      },
      {
        test: /\.js$/,
        use: "babel-loader",
        exclude: /node_modules/
      },
      {
        test: /\.vue$/,
        use: "vue-loader"
      },
      {
        test: /\.css/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.(ttf|eot|svg|woff|woff2)$/,
        use: 'url-loader'
      },
      {
        test: /\.(jpg|png|jpeg|webp|gif)$/,
        use: 'url-loader?limit=8192'
      }
    ]
  }
}